package com.itheima.mapper;

import com.itheima.pojp.Dept;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DeptMapper {
    /**
     * 查询部门信息
     * @return
     */
   /*@Results({
            @Result(column = "create_time",property = "createTime"),
            @Result(column = "update_time",property = "updateTime"),
    })*/
    //@Select("select id,name,create_time,update_time from dept order by update_time desc")
    @Select("select * from dept order by update_time desc")
    List<Dept> list();
    /**
     * 根据id删除部门
     *
     */
    @Delete("delete from dept where id=#{id}")
    void delete(Integer deptId);

    /**
     * 保存部门
     * @param dept
     */
    @Insert("insert into dept(name,create_time,update_time) values(#{name},#{createTime},#{updateTime})")
    void save(Dept dept);

    /**
     * 根据id查询部门
     * @param id
     * @return
     */
    @Select("select id, name,create_time,update_time from dept where where id = #{id}")
    Dept getById(Integer id);
    /**
     * 修改部门
     * @param dept
     */
    void update(Dept dept);
}